clear;
clc;
figure;
 
box off

load('Simu_NoJ_data_Tn_10_nobs_546_qn_21')

M = 1000;
subplot(2,2,4)
nbin = 120;
binCtrs = linspace(-0.4,0.4,nbin);
binWidth=binCtrs(2)-binCtrs(1);  

counts = hist(LambdaT_C',binCtrs);
prob = counts / (M * binWidth);   
h1 = bar(binCtrs,prob,'FaceColor',[0 0 1],'EdgeColor',[0 0 1],'FaceAlpha',1.0);


hold on
counts = hist(Lambda_hat_AJX(1,:)',binCtrs);
prob = counts / (M * binWidth);   
h3 = bar(binCtrs,prob,'FaceColor',[0. 0. 0.6],'EdgeColor',[0. 0. 0.6],'FaceAlpha',0.5);

set([h1,h3], {'DisplayName'}, {'$\Lambda^C$','$\widehat{\Lambda}^C$'}')

legend('interpreter','latex') 
box off


subplot(2,2,3)
nbin = 120;
binCtrs = linspace(-0.4,0.4,nbin);
binWidth=binCtrs(2)-binCtrs(1);  

counts = hist(LambdaT_C',binCtrs);
prob = counts / (M * binWidth);   
h5 = bar(binCtrs,prob,'FaceColor',[0 0 1],'EdgeColor',[0 0 1],'FaceAlpha',1.0);

hold on
counts = hist(Lambda_hat,binCtrs);
prob = counts / (M * binWidth);   
h7 = bar(binCtrs,prob,'FaceColor',[0 0. 0],'EdgeColor',[0 0. 0.],'FaceAlpha',0.5);

set([h5,h7], {'DisplayName'}, {'$\Lambda^C$','Classical Fama-MacBeth'}')

legend('interpreter','latex') 

box off

load('Simu_data_Tn_10_nobs_546_qn_21')

box off;
M = 1000;
subplot(2,2,2)
nbin = 120;
binCtrs = linspace(-0.4,0.4,nbin);
binWidth=binCtrs(2)-binCtrs(1);  


hold on
counts = hist(Lambda_hat_AJX(1,:)',binCtrs);
prob = counts / (M * binWidth);   
h3 = bar(binCtrs,prob,'FaceColor',[0 0 0.6],'EdgeColor',[0 0 0.6],'FaceAlpha',0.5);


hold on
counts = hist(Lambda_hat_AJX(2,:)',binCtrs);
prob = counts / (M * binWidth);   
h4 = bar(binCtrs,prob,'FaceColor',[0.6 0 0],'EdgeColor',[0.6 0 0],'FaceAlpha',0.5);
hold on;
h1=plot([LambdaT_C(1),LambdaT_C(1)],[0,10],'b--','LineWidth',2);

hold on;
h2=plot([LambdaT_J(1),LambdaT_J(1)],[0,10],'r--','LineWidth',2);

set([h1,h2,h3,h4], {'DisplayName'}, {'${\Lambda}^C$','${\Lambda}^J$','$\widehat{\Lambda}^C$','$\widehat{\Lambda}^J$'}')
legend('interpreter','latex') 



subplot(2,2,1)
nbin = 120;
binCtrs = linspace(-0.4,0.4,nbin);
binWidth=binCtrs(2)-binCtrs(1);  


hold on
counts = hist(Lambda_hat,binCtrs);
prob = counts / (M * binWidth);   
h7 = bar(binCtrs,prob,'FaceColor',[0 0 0],'EdgeColor',[0 0 0],'FaceAlpha',0.5);
hold on;
h5=plot([LambdaT_C(1),LambdaT_C(1)],[0,10],'b--','LineWidth',2);

hold on;
h6=plot([LambdaT_J(1),LambdaT_J(1)],[0,10],'r--','LineWidth',2);



set([h5,h6,h7], {'DisplayName'}, {'${\Lambda}^C$','${\Lambda}^J$','Classical Fama-MacBeth'}')
legend('interpreter','latex') 

box off

ax = gcf;
exportgraphics(ax,'comp.pdf','Resolution',300) 